<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<link rel="stylesheet" href="${ctx}/static/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript"
	src="${ctx}/static/js/jquery-1.7.1.min.js"></script>
<script src="${ctx}/static/js/jquery.ztree.all-3.5.js"></script>
<script src="${ctx}/static/js/showDiv.js"></script>

<c:set var="queryList"
	value="${pageContext.request.contextPath}/dic/list" />

<div class="crumbs">
	<p>
		<i class="fa fa-home"></i> 字典管理 > <span class="active ml5"></span>
	</p>
	<div class="crumbs-line"></div>
</div>

<div class="content">
	<div class="right-cot w100">
		<div class="crumbs">
			<p>
			<span class="active ml5"><i class="fa fa-user"></i>  字典管理列表</span>
			</p>
			<div class="crumbs-line"></div>
		</div>
		<div class="right-form">
			<form id="dicQueryForm" action="" class="form-inline"
				onsubmit="return false;">
				<div class="form-group">
					<label for="dcName">字典名:</label> <input type="text" name="dcName"
						value="${dcName }" />
				</div>

				<div class="form-group">
					<label for="dcCode">编码:</label> <input type="text" name="dcCode"
						value="${dcCode }" />
				</div>

				<div class="form-group">
					<label for="postName">状态:</label>
					<select value="${dcIsDeleted}" name="dcIsDeleted" style="">
						<option value="0"
							<c:if test="${ '0' eq dcIsDeleted }">selected='selected'</c:if>>启用</option>
						<option value="1"
							<c:if test="${ '1' eq dcIsDeleted }">selected='selected'</c:if>>停用</option>
					</select>
				</div>

				<div class="form-group" style="clear: both">
					所属系统：<input id="s_dcSysName" name="dcSysName" class="inputText_sm"
						value="${dcSysName}" type="text"> 
						<input id="s_dcSysCode"
						name="dcSysCode" type="hidden" value="${dcSysCode}" >
				</div>
				<div class="form-group">
					上级字典：<input id="s_pCodeName" name="pCodeName" class="inputText_sm"
						value="${pCodeName}" type="text"> <input id="s_dcPcode"
						name="dcPcode" type="hidden" value="${dcPcode}"  >

				</div>
				
				<div class="form-right">
					<button type="button" class="btn btn-orange"
						onclick="changePage('${queryList }','#dicQueryForm','1','${pageBean.pageSize }',0)">
						<i class="fa fa-search"></i> 查 询
					</button>
				</div>
			</form>
		</div>
		<div class="table-scroll">

			<div class="form-top">
				<div class="mb10">
					<button class="btn btn-default"
						onclick="goUpdate('${ctx}/dic/goEdit','新增字典')">
						<i class="fa fa-plus"></i> 新 增
					</button>
				</div>
			</div>

			<table class="table-form table-bordered">
				<thead>
					<tr>
						<th>序号</th>
						<th>字典名</th>
						<th>字典编码</th>
						<th>所属系统</th>
						<th>创建时间</th>
						<th>创建人</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${not empty pageBean.data}"></c:if>
					<c:forEach items="${pageBean.data}" var="dic" varStatus="seq">
						<tr>
							<td>${seq.count+pageBean.first}</td>
							<td style="text-align:left">${dic.dcName}</td>
							<td style="text-align:left">${dic.dcCode}</td>
							<td style="text-align:left">${dic.dcSysName}</td>
							<td>${dic.dcCreateTime}</td>
							<td>${dic.dcCreateUser}</td>
							<td><c:out value="${'1' eq dic.dcIsDeleted?'停用':'启用'}" /></td>
							<td><a
								onclick="goUpdate('${ctx}/dic/goEdit?dicId=${dic.dcId}&currentPage=${pageBean.currentPage}&pageSize=${pageBean.pageSize }','修改字典信息')"
								href="javascript:void(0);" class="link-blue mr5"><i
									class="fa fa-pencil"></i>修改</a> <a
								onclick="deleteById('${dic.dcId}')" href="#"
								class="link-blue mr5"><i class="fa fa-close"></i>停用</a></td>
						</tr>
					</c:forEach>

				</tbody>
			</table>
		</div>

		<div class="pages">
			<div class="dataTables-length">
				 每页记录 <select aria-controls="dynamic-table"
					class="form-page"
					onchange="changePage('${queryList }','#dicQueryForm','1',$(this).val(),${pageBean.totalPage})">
						<option
							<c:if test="${pageBean.pageSize eq 10}">selected='selected'</c:if>
							value="10">10</option>
						<option
							<c:if test="${pageBean.pageSize eq 25}">selected='selected'</c:if>
							value="25">25</option>
						<option
							<c:if test="${pageBean.pageSize eq 50}">selected='selected'</c:if>
							value="50">50</option>
						<option
							<c:if test="${pageBean.pageSize eq 100}">selected='selected'</c:if>
							value="100">100</option>
				</select> <span class="ml5">共${pageBean.totalCount}条记录</span>
				 
			</div>
			<div class="dataTables-paginate pull-right">
				<ul class="pagination-dic">

					<li
						onclick="changePage('${queryList}','#dicQueryForm','1','${pageBean.pageSize }')"><a
						href="#">首页</a></li>

					<c:if test="${pageBean.hasPreviousPage == true }">
						<li
							onclick="changePage('${queryList}','#dicQueryForm','${pageBean.currentPage-1}','${pageBean.pageSize }')"><a
							href="#">上一页</a></li>
					</c:if>

					<li><input
							id="shouldChangePage" type="text" value="${pageBean.currentPage}"
							class="inp-number">&nbsp;/${pageBean.totalPage }&nbsp;</li>
					<li><button
							onclick="changePage('${queryList}','#dicQueryForm',$('#shouldChangePage').val(),'${pageBean.pageSize }')"
							class="pull-right btn-fresh mr5">跳转</button></li>

					<c:if test="${pageBean.hasNextPage == true }">
						<li
							onclick="changePage('${queryList}','#dicQueryForm','${pageBean.currentPage+1}','${pageBean.pageSize }')"><a
							href="#">下一页</a></li>
					</c:if>
					<li
						onclick="changePage('${queryList}','#dicQueryForm','${pageBean.totalPage}','${pageBean.pageSize }')"><a
						href="#">尾页</a></li>

				</ul>
			</div>
		</div>

		<div class="block20"></div>

	</div>
	<!--main end-->
</div>
<div id="treediv" style='top:75px;left:50px;overflow:scroll;display:none; position:absolute;width:300px;height:200px;background-color:#eeffdd; border:1px solid #BEC0BF;padding:5px;font-size:12px;'>
	<a onclick="hidetreediv();" href="#" class="link-red mr5" style="cursor:pointer;color:red;text-align:right;"><i class="fa fa-close"></i>取消</a>
	<ul id="tree" class="ztree"></ul>
</div>
<script type="text/javascript">

	$(document).ready(function() {

		$("#s_pCodeName").focus(function() {
			var divObj = $("#treediv");
			var txtObj = $("#s_pCodeName");
			showDiv(divObj,txtObj,dicsetting,"${ctx}/dic/getDics");
		});
		$("#s_dcSysName").focus(function() {
			/*$.get("${ctx}/dic/getsyses", function(data) {
				var json = eval('(' + data + ')');
				$.fn.zTree.init($("#tree"), appsetting, json);
				$("#treediv").css("left", $("#s_dcSysName").offset().left + $("#s_dcSysName").outerWidth());
				$("#treediv").css("top", $("#s_dcSysName").offset().top-20);
				$("#treediv").show();
			});*/
			var divObj = $("#treediv");
			var txtObj = $("#s_dcSysName");
			showDiv(divObj,txtObj,appsetting,"${ctx}/dic/getsyses");
		});

	});
	function deleteById(id) {
		layer.msg('是否继续执行操作？', {
			time : 0 //不自动关闭
			,
			btn : [ '确定', '取消' ],
			yes : function(index) {
				$.post("${ctx}/dic/deleteByIds/" + id, {}, function(result) {
					if (result.code == "success") {
						layer.msg('操作成功', {
							icon : 1
						});
						//setInterval("window.location.href='/standardmethod/index'",2000);
						//刷新列表
						changePage('${queryList }', '#dicQueryForm',  '${pageBean.currentPage}',
								'${pageBean.pageSize }', '${pageBean.totalPage}');
					} else {
						layer.msg('未知错误', {
							icon : 2
						});
					}
				}, "json");
			}
		});

	}

	function goUpdate(_url, _title) {

		layer.open({
			type : 2,
			title : _title,
			maxmin : false,
			shadeClose : false, //点击遮罩关闭层
			area : [ '800px', '550px' ],
			content : _url
		});
	}
</script>